package flc.ast;

import android.graphics.Color;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.ConvertFragment;
import flc.ast.fragment.EditFragment;
import flc.ast.fragment.GuessFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        mDataBinding.llHomeBottom.setOnClickListener(null);
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        StatusBarUtils.setSystemStatusTextColor(true,this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.llHome));
        listFragment.add(new FragmentViewBinder(GuessFragment.class,R.id.llGuess));
        listFragment.add(new FragmentViewBinder(ConvertFragment.class,R.id.llConvert));
        listFragment.add(new FragmentViewBinder(EditFragment.class,R.id.llEdit));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.ys1);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#FF060102"));
                break;
            case R.id.llGuess:
                mDataBinding.ivGuess.setImageResource(R.drawable.cj1);
                mDataBinding.tvGuess.setTextColor(Color.parseColor("#FF060102"));
                break;
            case R.id.llConvert:
                mDataBinding.ivConvert.setImageResource(R.drawable.zh1);
                mDataBinding.tvConvert.setTextColor(Color.parseColor("#FF060102"));
                break;
            case R.id.llEdit:
                mDataBinding.ivEdit.setImageResource(R.drawable.bj1);
                mDataBinding.tvEdit.setTextColor(Color.parseColor("#FF060102"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.wd1);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#FF060102"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.ys2);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#4D060102"));
        mDataBinding.ivGuess.setImageResource(R.drawable.cj2);
        mDataBinding.tvGuess.setTextColor(Color.parseColor("#4D060102"));
        mDataBinding.ivConvert.setImageResource(R.drawable.zh2);
        mDataBinding.tvConvert.setTextColor(Color.parseColor("#4D060102"));
        mDataBinding.ivEdit.setImageResource(R.drawable.bj2);
        mDataBinding.tvEdit.setTextColor(Color.parseColor("#4D060102"));
        mDataBinding.ivMy.setImageResource(R.drawable.wd2);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#4D060102"));
    }

}